<!--
 * @Date         : 2024-03-01 20:29:20
 * @LastEditTime : 2024-09-13 21:32:05
 * @description  : 
-->
<script setup>
const isyydt = import.meta.env.VITE_API_DEV_ENV == "yydt";
import router from "@/router";
import TheWelcome from "../components/TheWelcome.vue";
import { getExamInfo, getTrainExamProblem, getUserInfo, login } from "@/api/";
const ruleFormRef = ref();
const form = reactive({
  key: "b1e11b00-c54d-4156-bd0c-ddcb11d0d4dc",
  examinee_number: "233293023",
  password: "123456",
});
const rules = reactive({
  examinee_number: [{ required: true, message: "请输入账号", trigger: "blur" }],
  password: [{ required: true, message: "请输入密码", trigger: "blur" }],
});
// 进入模拟考试
const onSubmit = async (formEl) => {
  let startTime = sessionStorage.getItem("starttime-y");
  let isAns = +new Date() - startTime > 2 * 60 * 1000;
  if (isAns) {
    sessionStorage.setItem("endAnsTime", +new Date() + 20 * 60 * 1000);
    sessionStorage.setItem("starttime-y", +new Date());
    // let res = await getTrainExamProblem();
    // let { problem, exam_info } = res.data;
    // if (!problem || problem.length < 1) {
    //   ElMessage({
    //     showClose: true,
    //     message: "当前试卷没有题目,请联系老师",
    //     type: "error",
    //   });
    // } else {
    // }
    isyydt ? router.push("/Prescriptio") : router.push("/Prescriptio-zcydt");
  } else {
    ElMessage.error("请求过于频繁请稍后再试");
  }
  return;
};
const onClickPractice = () => {
  isyydt ? router.push("/listpage") : router.push("/listpage-zcydt");
};
onMounted(() => {
  sessionStorage.removeItem("problemList");
  sessionStorage.removeItem("startTime");
  sessionStorage.removeItem("endTime");
  sessionStorage.removeItem("endAnsTime");
});
</script>

<template>
  <div class="typePage">
    <div class="from">
      <div class="title">模拟考试</div>
      <el-form
        :model="form"
        label-width="auto"
        :rules="rules"
        ref="ruleFormRef"
        label-position="right"
        :hide-required-asterisk="true"
      >
        <!-- <el-form-item label="准考证号:" prop="examinee_number">
          <el-input
            style="width: 227px"
            v-model="form.examinee_number"
            placeholder="请输入准考证号"
          />
        </el-form-item>
        <el-form-item label="密码:" prop="password">
          <el-input
            style="width: 227px"
            v-model="form.password"
            type="password"
            placeholder="请输入密码"
          />
        </el-form-item> -->
      </el-form>
      <div class="onSubmit">
        <el-button
          type="primary"
          color="#652E1B"
          style="width: 180px; height: 39px"
          @click="onSubmit(ruleFormRef)"
        >
          进入
        </el-button>
      </div>
    </div>
    <div class="from" v-if="isyydt" style="margin-left: 20px">
      <div class="title">练习</div>
      <el-form
        :model="form"
        label-width="auto"
        :rules="rules"
        ref="ruleFormRef"
        label-position="right"
        :hide-required-asterisk="true"
      >
      </el-form>
      <div class="onSubmit">
        <el-button
          type="primary"
          color="#652E1B"
          style="width: 180px; height: 39px"
          @click="onClickPractice(ruleFormRef)"
        >
          进入
        </el-button>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.typePage {
  min-width: 100vw;
  height: 100%;
  background-image: url("https://cdn.yfzxzjysg.top/nxcsoft/bg20240310135118.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  .from {
    width: 551px;
    height: 370px;
    background-image: url("@/assets/login.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 37px;
    align-items: center;
    .title {
      color: #970702;
      font-size: 37px;
      text-align: center;
      padding: 37px 0;
      font-weight: 400;
    }
    .onSubmit {
      margin-top: 23px;
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
}
</style>
